/**
 *
 * @author Alex & Umit
 */
public class CircularListQueue implements Queue{

    private CircularList list;
    private int size;

    public CircularListQueue(){
        list = new CircularList();
        size = 0;
    }
    public int size(){
        return size;
    }

    public boolean isEmpty(){
        return size == 0;
    }

    public Object front() throws EmptyQueueException{
        Object res = null;
        if(!isEmpty()){
            res = list.first().element();
        }
        else throw new EmptyQueueException();
        return res;
    }

    public void enqueue(Object o){
        list.addLast(o);
        size++;
    }

    public Object dequeue() throws EmptyQueueException{
        Object res = null;
        if(!isEmpty()){
            res = list.remove(list.first());
        }
        else throw new EmptyQueueException();
        return res;
    }

    @Override
    public String toString(){
        return "<CircularListQueue[" + list.toString() + "]>";
    }
}
